﻿<div style="padding: 1px; overflow: hidden">
    <form id="ui_dead_reserve_form" method="post">
        <div title="预约殡仪馆" style="padding: 10px">
            <table style="width: 99%">
                <tr>                    
                    <th>死者姓名:</th>
                    <td>
                        <input type="hidden" name="ui_relative_id" id="ui_relative_id" />
                        <input type="hidden" name="ui_dead_id" id="ui_dead_id" />
                        <input class="easyui-textbox" name="ui_dead_name" id="ui_dead_name" readonly="readonly" />
                    </td>
                    
                </tr>
                <tr>
                    <th>联系人电话:</th>
                    <td colspan="3">                        
                        <input class="easyui-textbox" name="ui_relative_tel" id="ui_relative_tel" data-options="required:true" />
                    </td>

                </tr>
                <tr>
                    <th>联系人姓名:</th>
                    <td>
                        <input class="easyui-textbox" name="ui_relative_name" id="ui_relative_name" readonly="readonly"  />
                    </td>
                    
                </tr>
                <tr>
                    
                    <th>与死者关系:</th>
                    <td>
                        <input class="easyui-textbox" name="ui_relative_relation" id="ui_relative_relation" data-options="required:true" />
                    </td>
                </tr>
                
                
                <tr>
                    <th>预定殡仪馆名称:</th>
                    <td>
                        <select class="easyui-combobox" name="ui_dead_estArriveplace" id="ui_dead_estArriveplace" data-options="panelHeight:70,panelWidth:100, editable:false">
                            <option value="市殡仪馆A">市殡仪馆A</option>
                            <option value="市殡仪馆B">市殡仪馆B</option>
                            <option value="市殡仪馆C">市殡仪馆C</option>
                        </select>                        
                    </td>
                    
                </tr>
                <tr>
                    <th>预定到馆时间:</th>
                    <td>
                        <input class="easyui-datetimebox" id="ui_dead_estArrivetime" name="ui_dead_estArrivetime" data-options="required:true" />
                    </td>
                </tr>
            </table>
        </div>
    </form>
    <script>
        $(function () {
            $('#ui_relative_tel').textbox({
                prompt: '请输入电话进行查询',
                icons: [{
                    iconCls: 'icon-search',
                    handler: function (e) {
                        var tel = $(e.data.target).textbox('getValue');
                        getRelativeByTel(tel)
                    }
                }]
            });

            $("#ui_relative_tel").find('input').bind('keyup', function (ev) {
                alert(ev.target);
                if (ev.keyCode == '13') {
                    //处理回车，不生效？？？？               
                }
            });
        });

        function getRelativeByTel(tel) {
            if (!tel) {
                $.show_warning("提示", "请输入联系人电话！");
                return;
            }
            para = {};
            para.action = "getRelativeByTel";
            para.timespan = new Date().getTime();
            para.tel = tel;
            $.ajax({
                url: "ashx/bg_relative.ashx",
                data: para,
                type: "POST",
                dataType: "json",
                success: function (data) {
                    var dr = data.msg;
                    if (data.success && dr) {
                        $('#ui_relative_id').val(dr.id);
                        $('#ui_relative_name').textbox('setValue', dr.name);
                        $('#ui_relative_tel').textbox('setValue', dr.tel);
                    } else {
                        $('#ui_relative_id').val(0);
                        $('#ui_relative_name').textbox('setValue', "");
                        if (dr) {
                            $.show_warning("提示", data.msg);
                        } else {
                            $.show_warning("提示", "联系人不存在，请先添加！");
                        }
                    }
                }
            });
        }
        function uploadImage() {
            var v = $("#ui_upload_photo_file").val();
            //判断是否选择图片  
            if (v == null || v == "") {
                $.messager.alert('提示', '请选择图片!');
                $("#ui_upload_photo_file").focus();
                return;
            }
            var options = {
                type: "POST",
                url: 'ashx/upload_image.ashx',
                success: function (data) {
                    var res = eval('(' + data + ')');    //转成json格式
                    if (res.success) {
                        $('#ui_dead_photo_img').attr('src', res.content);
                        $('#ui_dead_photo').val(res.content);
                        //$.messager.alert('提示', '上传成功！');
                    } else {
                        $.messager.alert('提示', res.content);
                    }
                }
            };
            // 将options传给ajaxForm  
            $('#ui_dead_editform').ajaxSubmit(options);
        }
    </script>
</div>
